import { createSlice } from "@reduxjs/toolkit";
import axios from "axios";
const cityStore=createSlice({
  name:'city',
  initialState:{cityList:[],count:0},
  reducers:{
    setCity:(state,actions)=>{state.cityList=actions.payload},
    addToTen:(state,actions)=>{state.count=actions.payload}
  }
})
const{setCity,addToTen}=cityStore.actions
const fetchCityList=()=>{
  return async dispatch=>{
    const res=await axios.get('http://localhost:5000')
    dispatch(setCity(res.data))
  }
}
const cityReducer=cityStore.reducer
export {fetchCityList,addToTen}
export default cityReducer